<?php

class ContactUsForm extends BaseForm {

  const FORM_NAME = 'frm';
  const FIELD_FIRST_NAME = 'first_name';
  const FIELD_LAST_NAME = 'last_name';
  const FIELD_EMAIL = 'email';
  const FIELD_PHONE = 'phone';
  const FIELD_COMMENTS = 'comments';

  public function configure() {

    $widgets = array(
        self::FIELD_FIRST_NAME => new sfWidgetFormInput(array(), array('maxlength' => 255)),
        self::FIELD_LAST_NAME => new sfWidgetFormInput(array(), array('maxlength' => 255)),
        self::FIELD_EMAIL => new sfWidgetFormInput(array(), array('maxlength' => 255)),
        self::FIELD_PHONE => new sfWidgetFormInput(array(), array('maxlength' => 30)),
        self::FIELD_COMMENTS => new sfWidgetFormTextarea(array(), array())
    );

    $this->setWidgets($widgets);

    $validators = array(
        self::FIELD_FIRST_NAME => new sfValidatorString(array('trim' => true), array('required' => 'Please enter your First Name')),
        self::FIELD_LAST_NAME => new sfValidatorString(array('trim' => true), array('required' => 'Please enter your Last Name')),
        self::FIELD_EMAIL => new sfValidatorEmail(array('trim' => true), array('required' => 'Please enter your Email Address', 'invalid' => 'Please enter a valid Email Address')),
        self::FIELD_COMMENTS => new sfValidatorString(array('trim' => true), array('required' => 'Please enter Message'))
    );

    $this->setValidators($validators);

    $this->widgetSchema->setNameFormat(self::FORM_NAME . '[%s]');

    $this->validatorSchema->setOption('allow_extra_fields', true);
    $this->validatorSchema->setOption('filter_extra_fields', false);
  }

}

?>